/**
 * 布局设置
 */
import { defineStore } from 'pinia';
import { Setting } from '@/types/common/setting.ts';
import { images_common } from '@/utils/common/utils.ts';

export const setting = defineStore('setting', {
  state: (): Setting => {
    return {
      body: 'Default',
      header: 'Default',
      entity: 'Default',
      more: 'Default',
      logoSmall: images_common('logo.png'),
      logoBg: images_common('logo_bg.png'),
    };
  },
  getters: {
    body: (state) => state.body,
    header: (state) => state.header,
    entity: (state) => state.entity,
    more: (state) => state.more,
    logoSmall: (state) => state.logoSmall,
    logo: (state) => state.logoBg,
  },
  actions: {
    // 更新默认布局
    updateLayoutBody(body: string) {
      this.$state.body = body;
    },
    // 更新网站头默认布局
    updateLayoutHeader(header: string) {
      this.$state.header = header;
    },
    // 更新entity默认布局
    updateLayoutEntity(entity: string) {
      this.$state.entity = entity;
    },
    // 更新更多页面默认布局
    updateLayoutMore(more: string) {
      this.$state.more = more;
    },
  },
  persist: {
    storage: window.localStorage,
  },
});
